package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;

public class PI extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    int i = paramArrayOfObject.length;
    if (i == 0)
      return new Double(3.141592653589793D);
    if (i == 1)
    {
      Object localObject = paramArrayOfObject[0];
      if (localObject instanceof Integer)
        return new Double(3.141592653589793D * ((Integer)localObject).intValue());
      return Primitive.ERROR_VALUE;
    }
    return Primitive.ERROR_VALUE;
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getCN()
  {
    return "PI(number): 是一个数学常量函数，当number为空时，函数返回精确到15位的数值3.141592653589793；当参数不为空时，number表示PI的倍数。\n示例:\nSIN(PI()/2)等于1。\n计算圆的面积的公式: S=PI()*(r^2)，其中S为圆的面积，R为圆的半径。\nPI(3)等于9.42477796076938。";
  }

  public String getEN()
  {
    return "PI: Returns the number 3.14159265358979, the mathematical constant pi, accurate to 15 digits.\n\nExample:\n   SIN(PI()/2) = 1。\n   Formula for area of a circle: S=PI()*(r^2), S is the area, R is the radius.";
  }
}